package com.qihoo.finance.lcs;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Generator {

    private String database;
    private String key;
    private List<String> tables;

    public Generator(String database, String key, List<String> tables) {
        this.database = database;
        this.key = key;
        this.tables = tables;
    }

    public Map<String, String> generate(){
        Map<String, String> result = new HashMap<>();
        for(String table:tables){
            String content = getContent(database, key, table);
            result.put(database+"-"+table, content);
        }
        return result;
    }


    private String getContent(String database, String topic, String table){
        return  "dataSourceKey: "+ database+"\n" +
                "destination: "+topic+"\n" +
                "groupId: "+database+"\n" +
                "outerAdapterKey: "+database+"\n" +
                "concurrent: true\n" +
                "dbMapping:\n" +
                "  database: "+database+"\n" +
                "  table: "+table+"\n" +
                "  targetTable: "+database+"."+table+"\n" +
                "  targetPk:\n" +
                "    id: id\n" +
                "  mapAll: true\n" +
                "#  targetColumns:\n" +
                "#    id:\n" +
                "#    name:\n" +
                "#    role_id:\n" +
                "#    c_time:\n" +
                "#    test1:\n" +
                "  etlCondition: \"where c_time>={}\"\n" +
                "  commitBatch: 3000 # 批量提交的大小";
    }

}
